package com.hehe.ConfigInterceptor;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class URLInterceptor implements WebMvcConfigurer {

    @Autowired
    private UserInterceptor userInterceptor;

    @Autowired
    private AdminInterceptor adminInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userInterceptor)
                .addPathPatterns( "/login-success", "/my-space") // 只拦截 /aaa 和 /bbb 路径
                .excludePathPatterns("/login",  "/resources/**", "/static/**", "/public/**", "/webjars/**"); // 排除登录页面和静态资源


        registry.addInterceptor(adminInterceptor)
                .addPathPatterns("/admin/**") // 需要管理员权限的页面
                .excludePathPatterns("/login", "/resources/**", "/static/**", "/public/**", "/webjars/**"); // 排除登录页面和静态资源


    }
}


